﻿using GraphQL.Resolvers;
using GraphQL.Subscription;
using GraphQL.Types;
using GraphQLSample.Domain.Core;
using System;
using System.Collections.Generic;
using System.Text;

namespace GraphQLSample.Domain.Schema
{
    public class UserSubscription
        : ObjectGraphType
    {
        public UserSubscription()
        {
            Name = "Subscription";
            Description = "";

            AddField(new EventStreamFieldType()
            {
                Name = nameof(UserEventType),
                Description = "",
                Type = typeof(UserEventType),
                Resolver = new FuncFieldResolver<UserEvent>(Resolve),
                Subscriber = new EventStreamResolver<UserEvent>(Subscribe)
            });
        }

        private IObservable<UserEvent> Subscribe(ResolveEventStreamContext arg)
        {
            throw new NotImplementedException();
        }

        private UserEvent Resolve(ResolveFieldContext arg)
        {
            return arg.Source as UserEvent;
        }
    }
}
